﻿using Mengsk.ProxyDelivery.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Print.Domain.PrintDataFormatters
{
    class PrintDataFormatterGoods_Count : PrintDataFormatter
    {

        public override PrintTemplateItemTypes AcceptType
        {
            get { return PrintTemplateItemTypes.GOODS_COUNT; }
        }

        public override object Format(PrintTemplate template, PrintTemplateItem item, Order order)
        {
            if (order.OrderGoodss == null || order.OrderGoodss.Count < 1)
            {
                return "";
            }

            var goods = order.OrderGoodss.Where(obj => obj.State != OrderState.Closed && obj.State != OrderState.Cancled && obj.State != OrderState.Notsale && obj.State != OrderState.Spilted);
            var count = goods.Select(obj => obj.Count).Sum();
            return count.ToString();
        }
    }
}
